Skip to content

fix(gateway): honour declared lengths when sniffing SNI - #1602

Merged
kvinwang merged 1 commit into
nextfrom
fix/gateway-sni-declared-lengths
Nov 18, 2026
Merged

kvinwang merged 1 commit into
nextfrom
fix/gateway-sni-declared-lengths

Conversation

@kvinwang

Copy link
Copy Markdown
Collaborator

extract_sni ignored the declared record, handshake, extensions-block and ServerNameList lengths, so a server_name placed outside them (e.g. after an extensions block declared empty) was still returned. The parser now reads each block only within its declared length and rejects inconsistent lengths. Partial buffers still parse as far as they go, so split reads behave as before; a ClientHello fragmented over records is parsed within the first record.

Security impact is low: the sniffed name picks the backend while the TLS stack parses the same ClientHello, so this was a mismatch between two parsers of the client's own bytes rather than a bypass. Routing should still agree with what TLS sees.

Found by the Lean model of the parser (#1597, Sni.lean).

kvinwang added a commit that referenced this pull request Nov 18, 2026
CertLock follows #1599-#1601 on wavekv 2.2: the lock value carries a
nonce, a lease stamped beyond the drift bound counts as expired, and
release and lease-guarded writes are no-ops once the lease expired by the
local clock. The force-release, clock-step-back and stale-release
counterexamples become positive theorems: ownership on one node under any
clock, and a release or guarded commit losing LWW to any successor whose
clock is within the drift bound. The replication gap, skew beyond the
drift bound, and cross-node force release remain as counterexamples.

Sni follows #1602: the returned name lies within every declared block.
CertStore follows #1603: no exact-match table, empty first label refused.

Signed-off-by: Kevin Wang <wy721@qq.com>
@kvinwang
kvinwang enabled auto-merge November 18, 2026 08:46
extract_sni read the record, handshake, extensions and ServerNameList
lengths but ignored them, scanning on until the buffer ran out. A
server_name extension placed after an extensions block declared empty, or
after the end of the first record, was still returned.

Parse each block only within its declared length, truncated to the bytes
received so far so a ClientHello arriving over several reads still parses
as before, and reject an extensions or ServerNameList length that does not
fill its enclosing block or an extension longer than the space left.

Security: low. The sniffed name picks the backend app (and, when
terminating, the route) while the TLS stack later parses the same
ClientHello and would see a different name or reject it. The client
controls both views of its own hello, so this is a parser differential
rather than a bypass, but routing should agree with what TLS sees.

Signed-off-by: Kevin Wang <wy721@qq.com>
@kvinwang
kvinwang force-pushed the fix/gateway-sni-declared-lengths branch from 50f0d34 to f62e7e2 Compare November 18, 2026 09:36
@kvinwang
kvinwang merged commit 47a1ce1 into next Nov 18, 2026
21 checks passed
@kvinwang
kvinwang deleted the fix/gateway-sni-declared-lengths branch November 18, 2026 09:50
kvinwang added a commit that referenced this pull request Nov 18, 2026
CertLock follows #1599-#1601 on wavekv 2.2: the lock value carries a
nonce, a lease stamped beyond the drift bound counts as expired, and
release and lease-guarded writes are no-ops once the lease expired by the
local clock. The force-release, clock-step-back and stale-release
counterexamples become positive theorems: ownership on one node under any
clock, and a release or guarded commit losing LWW to any successor whose
clock is within the drift bound. The replication gap, skew beyond the
drift bound, and cross-node force release remain as counterexamples.

Sni follows #1602: the returned name lies within every declared block.
CertStore follows #1603: no exact-match table, empty first label refused.

Signed-off-by: Kevin Wang <wy721@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant